%1. change the FileNAME/ FileNAME1
%2. Make sure name of ROIs
%After converting to MNI coordinates



% a description of what it does:
% after ROI analysis, this script calculate means and std_error based
% on the beta values extracted 

% written by Roy Seo 07/07/2015
  % modified 
  
clc 
clear all
close all hidden


FileName  = 'MNI_ROI5_diff_mm';
%for figure title
FileName1 = 'MNI ROI5 diff mm';


%Contrasts of Interest: out of 125 contrasts: I need these 6.
   cond1 = 'Encode_Eng_Lang - All Sessions';
   cond2 = 'Encode_Spa_Lang - All Sessions';
   cond3 = 'Encode_Eng_(Noun+Verb+Comb) - All Sessions';
   cond4 = 'Encode_Spa_(Noun+Verb+Comb) - All Sessions';
   cond5 = 'Execut_Eng_(Noun+Verb+Comb) - All Sessions';
   cond6 = 'Execut_Spa_(Noun+Verb+Comb) - All Sessions';
   
% read the excel file that include the betas
    [num, txt, raw] =xlsread(strcat(FileName,'.xlsx'));
   %[num, txt, raw] =xlsread('MNI_ROI3_8mm_no_PreSMA.xlsx');
   
%   from the raw file, I grab the header
   results_ref = raw (1,:);
%   from the raw file, I grab the data except for the header
   results_txt = raw(2:end,:);
%  index number that has cond1,2,3,4,5,6,    
   encode.index_con1 = find(strcmp(results_txt(:, strcmp(results_ref,'2.Contrast')),cond1));
   encode.index_con2 = find(strcmp(results_txt(:, strcmp(results_ref,'2.Contrast')),cond2));
   encode.index_con3 = find(strcmp(results_txt(:, strcmp(results_ref,'2.Contrast')),cond3));
   encode.index_con4 = find(strcmp(results_txt(:, strcmp(results_ref,'2.Contrast')),cond4));
   encode.index_con5 = find(strcmp(results_txt(:, strcmp(results_ref,'2.Contrast')),cond5));
   encode.index_con6 = find(strcmp(results_txt(:, strcmp(results_ref,'2.Contrast')),cond6));
   
% grab the con 1,2,3,4,5,6, using the encode.index_con1
  grab_con1 = raw((encode.index_con1)+1,:);
  grab_con2 = raw((encode.index_con2)+1,:);
  grab_con3 = raw((encode.index_con3)+1,:);
  grab_con4 = raw((encode.index_con4)+1,:);
  grab_con5 = raw((encode.index_con5)+1,:);
  grab_con6 = raw((encode.index_con6)+1,:);
  

%sort out by ROIs in a grab_conX  
   roi_1 = 'sphere_10-0_32_24_AnteriorCingulate';
   roi_2 = 'sphere_8--31_18_-2_LInferiorFrontalGyrus(BA47)';
   roi_3 = 'sphere_8--44_13_29_LMiddleFrontalGyrus(BA46)';  
   roi_4 = 'sphere_8--48_-42_-6_LMiddleTemporalGyrus(BA37)';
   roi_5 = 'sphere_8--48_15_11_LInferiorFrontalGyrus(BA44)';
   roi_6 = 'sphere_6-14_5_16_RCaudate';
   roi_7 = 'sphere_8-40_-9_32_RPrecentralCyrus(BA6)';
   roi_8 = 'sphere_10-1_1_57_MidlinePreSMA(BA6)';
   roi_9 = 'sphere_6--14_5_16_LCaudate';


   
   
   % 1. roi_1 = 'sphere_10-0_32_24_AnteriorCingulate'
        
        % from con1
           AnteriorCingulate_con1.index = find(strcmp(grab_con1(:, strcmp(results_ref,'3.ROI')),roi_1));
            grab_roi1_con1 = grab_con1((AnteriorCingulate_con1.index),:);
                %grab betas
                 roi1_con1_beta = grab_roi1_con1(:,4);
                 roi1_con1_betas = cell2mat(roi1_con1_beta);
                 
        % from con2
           AnteriorCingulate_con2.index = find(strcmp(grab_con2(:, strcmp(results_ref,'3.ROI')),roi_1));
            grab_roi1_con2 = grab_con2((AnteriorCingulate_con2.index),:);
                %grab betas
                 roi1_con2_beta = grab_roi1_con2(:,4);
                 roi1_con2_betas = cell2mat(roi1_con2_beta);
        %from con3
           AnteriorCingulate_con3.index = find(strcmp(grab_con3(:, strcmp(results_ref,'3.ROI')),roi_1));
            grab_roi1_con3 = grab_con3((AnteriorCingulate_con3.index),:);
                 %grab betas
                  roi1_con3_beta = grab_roi1_con3(:,4);
                  roi1_con3_betas = cell2mat(roi1_con3_beta);
        %from con4
           AnteriorCingulate_con4.index = find(strcmp(grab_con4(:, strcmp(results_ref,'3.ROI')),roi_1));
            grab_roi1_con4= grab_con4((AnteriorCingulate_con4.index),:);
                 %grab betas
                 roi1_con4_beta = grab_roi1_con4(:,4);
                 roi1_con4_betas = cell2mat(roi1_con4_beta);
        %from con5
           AnteriorCingulate_con5.index = find(strcmp(grab_con5(:, strcmp(results_ref,'3.ROI')),roi_1));
            grab_roi1_con5= grab_con5((AnteriorCingulate_con5.index),:);
                %grab betas
                roi1_con5_beta = grab_roi1_con5(:,4);
                roi1_con5_betas = cell2mat(roi1_con5_beta);
        % from con6
           AnteriorCingulate_con6.index = find(strcmp(grab_con6(:, strcmp(results_ref,'3.ROI')),roi_1));
            grab_roi1_con6 = grab_con6((AnteriorCingulate_con6.index),:);
                %grab betas
                roi1_con6_beta = grab_roi1_con6(:,4);
                roi1_con6_betas = cell2mat(roi1_con6_beta);
    
  
   % 2. roi_2 = 'sphere_8--31_18_-2_LInferiorFrontalGyrus(BA47)'

        % from con1
            LInferiorFrontalGyrus_BA47_con1.index = find(strcmp(grab_con1(:, strcmp(results_ref,'3.ROI')),roi_2));
            grab_roi2_con1 = grab_con1((LInferiorFrontalGyrus_BA47_con1.index),:);
                %grab betas
                 roi2_con1_beta = grab_roi2_con1(:,4);
                 roi2_con1_betas = cell2mat(roi2_con1_beta);
        % from con2
            LInferiorFrontalGyrus_BA47_con2.index = find(strcmp(grab_con2(:, strcmp(results_ref,'3.ROI')),roi_2));
            grab_roi2_con2 = grab_con2((LInferiorFrontalGyrus_BA47_con2.index),:);
                 %grab betas
                 roi2_con2_beta = grab_roi2_con2(:,4);
                 roi2_con2_betas = cell2mat(roi2_con2_beta);
        %from con3
            LInferiorFrontalGyrus_BA47_con3.index = find(strcmp(grab_con3(:, strcmp(results_ref,'3.ROI')),roi_2));
            grab_roi2_con3 = grab_con3((LInferiorFrontalGyrus_BA47_con3.index),:);
                %grab betas
                 roi2_con3_beta = grab_roi2_con3(:,4);
                 roi2_con3_betas = cell2mat(roi2_con3_beta);
        %from con4
            LInferiorFrontalGyrus_BA47_con4.index = find(strcmp(grab_con4(:, strcmp(results_ref,'3.ROI')),roi_2));
            grab_roi2_con4= grab_con4((LInferiorFrontalGyrus_BA47_con4.index),:);
                %grab betas
                 roi2_con4_beta = grab_roi2_con4(:,4);
                 roi2_con4_betas = cell2mat(roi2_con4_beta);
        %from con5
            LInferiorFrontalGyrus_BA47_con5.index = find(strcmp(grab_con5(:, strcmp(results_ref,'3.ROI')),roi_2));
            grab_roi2_con5= grab_con5((LInferiorFrontalGyrus_BA47_con5.index),:);
                %grab betas
                 roi2_con5_beta = grab_roi2_con5(:,4);
                 roi2_con5_betas = cell2mat(roi2_con5_beta);
        %from con6
            LInferiorFrontalGyrus_BA47_con6.index = find(strcmp(grab_con6(:, strcmp(results_ref,'3.ROI')),roi_2));
            grab_roi2_con6 = grab_con6((LInferiorFrontalGyrus_BA47_con6.index),:);
                %grab betas
                 roi2_con6_beta = grab_roi2_con6(:,4);
                 roi2_con6_betas = cell2mat(roi2_con6_beta);
   
            
    % 3.roi_3 = 'sphere_8--44_13_29_LMiddleFrontalGyrus(BA46)'
        
        % from con1
           LMiddleFrontalGyrus_BA46_con1.index = find(strcmp(grab_con1(:, strcmp(results_ref,'3.ROI')),roi_3));
            grab_roi3_con1 = grab_con1((LMiddleFrontalGyrus_BA46_con1.index),:);
                %grab betas
                 roi3_con1_beta = grab_roi3_con1(:,4);
                 roi3_con1_betas = cell2mat(roi3_con1_beta);
        % from con2
           LMiddleFrontalGyrus_BA46_con2.index = find(strcmp(grab_con2(:, strcmp(results_ref,'3.ROI')),roi_3));
            grab_roi3_con2 = grab_con2((LMiddleFrontalGyrus_BA46_con2.index),:);
                %grab betas
                roi3_con2_beta = grab_roi3_con2(:,4);
                roi3_con2_betas = cell2mat(roi3_con2_beta);
        %from con3
           LMiddleFrontalGyrus_BA46_con3.index = find(strcmp(grab_con3(:, strcmp(results_ref,'3.ROI')),roi_3));
            grab_roi3_con3 = grab_con3((LMiddleFrontalGyrus_BA46_con3.index),:);
                %grab betas
                roi3_con3_beta = grab_roi3_con3(:,4);
                roi3_con3_betas = cell2mat(roi3_con3_beta);
        %from con4
           LMiddleFrontalGyrus_BA46_con4.index = find(strcmp(grab_con4(:, strcmp(results_ref,'3.ROI')),roi_3));
            grab_roi3_con4= grab_con4((LMiddleFrontalGyrus_BA46_con4.index),:);
                %grab betas
                roi3_con4_beta = grab_roi3_con4(:,4);
                roi3_con4_betas = cell2mat(roi3_con4_beta);
        %from con5
           LMiddleFrontalGyrus_BA46_con5.index = find(strcmp(grab_con5(:, strcmp(results_ref,'3.ROI')),roi_3));
            grab_roi3_con5= grab_con5((LMiddleFrontalGyrus_BA46_con5.index),:);
                %grab betas
                roi3_con5_beta = grab_roi3_con5(:,4);
                roi3_con5_betas = cell2mat(roi3_con5_beta);
        %from con6
           LMiddleFrontalGyrus_BA46_con6.index = find(strcmp(grab_con6(:, strcmp(results_ref,'3.ROI')),roi_3));
            grab_roi3_con6 = grab_con6((LMiddleFrontalGyrus_BA46_con6.index),:);
                 %grab betas
                roi3_con6_beta = grab_roi3_con6(:,4); 
                roi3_con6_betas = cell2mat(roi3_con6_beta);
   
            
    % 4. roi_4 = 'sphere_8--48_-42_-6_LMiddleTemporalGyrus(BA37)'
            
        % from con1
           LMiddleTemporalGyrus_BA37_con1.index = find(strcmp(grab_con1(:, strcmp(results_ref,'3.ROI')),roi_4));
            grab_roi4_con1 = grab_con1((LMiddleTemporalGyrus_BA37_con1.index),:);
                %grab betas
                roi4_con1_beta = grab_roi4_con1(:,4);
                roi4_con1_betas = cell2mat(roi4_con1_beta);
        % from con2
           LMiddleTemporalGyrus_BA37_con2.index = find(strcmp(grab_con2(:, strcmp(results_ref,'3.ROI')),roi_4));
            grab_roi4_con2 = grab_con2((LMiddleTemporalGyrus_BA37_con2.index),:);
                %grab betas
                roi4_con2_beta = grab_roi4_con2(:,4);
                roi4_con2_betas = cell2mat(roi4_con2_beta);
        %from con3
           LMiddleTemporalGyrus_BA37_con3.index = find(strcmp(grab_con3(:, strcmp(results_ref,'3.ROI')),roi_4));
            grab_roi4_con3 = grab_con3((LMiddleTemporalGyrus_BA37_con3.index),:);
                 %grab betas
                roi4_con3_beta = grab_roi4_con3(:,4);
                roi4_con3_betas = cell2mat(roi4_con3_beta);
        %from con4
           LMiddleTemporalGyrus_BA37_con4.index = find(strcmp(grab_con4(:, strcmp(results_ref,'3.ROI')),roi_4));
            grab_roi4_con4= grab_con4((LMiddleTemporalGyrus_BA37_con4.index),:);
                  %grab betas
                 roi4_con4_beta = grab_roi4_con4(:,4);
                 roi4_con4_betas = cell2mat(roi4_con4_beta);
        %from con5
           LMiddleTemporalGyrus_BA37_con5.index = find(strcmp(grab_con5(:, strcmp(results_ref,'3.ROI')),roi_4));
            grab_roi4_con5= grab_con5((LMiddleTemporalGyrus_BA37_con5.index),:);
                %grab betas
                roi4_con5_beta = grab_roi4_con5(:,4);
                roi4_con5_betas = cell2mat(roi4_con5_beta);
        %from con6
           LMiddleTemporalGyrus_BA37_con6.index = find(strcmp(grab_con6(:, strcmp(results_ref,'3.ROI')),roi_4));
            grab_roi4_con6 = grab_con6((LMiddleTemporalGyrus_BA37_con6.index),:);
                  %grab betas
                   roi4_con6_beta = grab_roi4_con6(:,4);
                   roi4_con6_betas = cell2mat(roi4_con6_beta);
                   
                   
 
  
 
                   
   % 5. roi_5 = 'sphere_8--48_15_11_LInferiorFrontalGyrus(BA44)'
            
       % from con1     
           LInferiorFrontalGyrus_BA44_con1.index = find(strcmp(grab_con1(:, strcmp(results_ref,'3.ROI')),roi_5));
            grab_roi5_con1 = grab_con1((LInferiorFrontalGyrus_BA44_con1.index),:);
                %grab betas
                roi5_con1_beta = grab_roi5_con1(:,4);
                roi5_con1_betas = cell2mat(roi5_con1_beta);
        % from con2
            LInferiorFrontalGyrus_BA44_con2.index = find(strcmp(grab_con2(:, strcmp(results_ref,'3.ROI')),roi_5));
            grab_roi5_con2 = grab_con2((LInferiorFrontalGyrus_BA44_con2.index),:);
                %grab betas
                roi5_con2_beta = grab_roi5_con2(:,4);
                roi5_con2_betas = cell2mat(roi5_con2_beta);
        %from con3
           LInferiorFrontalGyrus_BA44_con3.index = find(strcmp(grab_con3(:, strcmp(results_ref,'3.ROI')),roi_5));
            grab_roi5_con3 = grab_con3((LInferiorFrontalGyrus_BA44_con3.index),:);
                %grab betas 
                roi5_con3_beta = grab_roi5_con3(:,4);
                roi5_con3_betas = cell2mat(roi5_con3_beta);
        %from con4
           LInferiorFrontalGyrus_BA44_con4.index = find(strcmp(grab_con4(:, strcmp(results_ref,'3.ROI')),roi_5));
            grab_roi5_con4= grab_con4((LInferiorFrontalGyrus_BA44_con4.index),:);
                %grab betas 
                roi5_con4_beta = grab_roi5_con4(:,4);
                roi5_con4_betas = cell2mat(roi5_con4_beta);
        %from con5
           LInferiorFrontalGyrus_BA44_con5.index = find(strcmp(grab_con5(:, strcmp(results_ref,'3.ROI')),roi_5));
            grab_roi5_con5= grab_con5((LInferiorFrontalGyrus_BA44_con5.index),:);
                %grab betas 
                roi5_con5_beta = grab_roi5_con5(:,4);
                roi5_con5_betas = cell2mat(roi5_con5_beta);
        %from con6
           LInferiorFrontalGyrus_BA44_con6.index = find(strcmp(grab_con6(:, strcmp(results_ref,'3.ROI')),roi_5));
            grab_roi5_con6 = grab_con6((LInferiorFrontalGyrus_BA44_con6.index),:);
                  %grab betas 
                   roi5_con6_beta = grab_roi5_con6(:,4);
                   roi5_con6_betas = cell2mat(roi5_con6_beta);
   
    % 6.roi_6 = 'sphere_6-14_5_16_RCaudate' 
   
        % from con1    
            RCaudate_con1.index = find(strcmp(grab_con1(:, strcmp(results_ref,'3.ROI')),roi_6));
            grab_roi6_con1 = grab_con1((RCaudate_con1.index),:);
                  %grab betas 
                   roi6_con1_beta = grab_roi6_con1(:,4);
                   roi6_con1_betas = cell2mat(roi6_con1_beta);
        % from con2
            RCaudate_con2.index = find(strcmp(grab_con2(:, strcmp(results_ref,'3.ROI')),roi_6));
            grab_roi6_con2 = grab_con2((RCaudate_con2.index),:);
                 %grab betas 
                   roi6_con2_beta = grab_roi6_con2(:,4);
                   roi6_con2_betas = cell2mat(roi6_con2_beta);
        %from con3
            RCaudate_con3.index = find(strcmp(grab_con3(:, strcmp(results_ref,'3.ROI')),roi_6));
            grab_roi6_con3 = grab_con3((RCaudate_con3.index),:);
                 %grab betas 
                   roi6_con3_beta = grab_roi6_con3(:,4);
                   roi6_con3_betas = cell2mat(roi6_con3_beta);
        %from con4
            RCaudate_con4.index = find(strcmp(grab_con4(:, strcmp(results_ref,'3.ROI')),roi_6));
            grab_roi6_con4= grab_con4((RCaudate_con4.index),:);
                 %grab betas 
                   roi6_con4_beta = grab_roi6_con4(:,4);
                   roi6_con4_betas = cell2mat(roi6_con4_beta);
        %from con5
            RCaudate_con5.index = find(strcmp(grab_con5(:, strcmp(results_ref,'3.ROI')),roi_6));
            grab_roi6_con5= grab_con5((RCaudate_con5.index),:);
                 %grab betas 
                   roi6_con5_beta = grab_roi6_con5(:,4);
                   roi6_con5_betas = cell2mat(roi6_con5_beta);
        %from con6
            RCaudate_con6.index = find(strcmp(grab_con6(:, strcmp(results_ref,'3.ROI')),roi_6));
            grab_roi6_con6 = grab_con6((RCaudate_con6.index),:);
                 %grab betas 
                   roi6_con6_beta = grab_roi6_con6(:,4);
                   roi6_con6_betas = cell2mat(roi6_con6_beta);
   
    % 7. roi_7 = 'sphere_8-40_-9_32_RPrecentralCyrus(BA6)'
        
        %from con1
           RPrecentralGyrus_BA6_con1.index = find(strcmp(grab_con1(:, strcmp(results_ref,'3.ROI')),roi_7));
            grab_roi7_con1 = grab_con1((RPrecentralGyrus_BA6_con1.index),:);
                 %grab betas 
                   roi7_con1_beta = grab_roi7_con1(:,4);
                   roi7_con1_betas = cell2mat(roi7_con1_beta);
        % from con2
           RPrecentralGyrus_BA6_con2.index = find(strcmp(grab_con2(:, strcmp(results_ref,'3.ROI')),roi_7));
            grab_roi7_con2 = grab_con2((RPrecentralGyrus_BA6_con2.index),:);
              %grab betas 
                roi7_con2_beta = grab_roi7_con2(:,4);
                roi7_con2_betas = cell2mat(roi7_con2_beta);
        %from con3
           RPrecentralGyrus_BA6_con3.index = find(strcmp(grab_con3(:, strcmp(results_ref,'3.ROI')),roi_7));
            grab_roi7_con3 = grab_con3((RPrecentralGyrus_BA6_con3.index),:);
                %grab betas 
              roi7_con3_beta = grab_roi7_con3(:,4);
              roi7_con3_betas = cell2mat(roi7_con3_beta);
        %from con4
           RPrecentralGyrus_BA6_con4.index = find(strcmp(grab_con4(:, strcmp(results_ref,'3.ROI')),roi_7));
            grab_roi7_con4= grab_con4((RPrecentralGyrus_BA6_con4.index),:);
                %grab betas 
              roi7_con4_beta = grab_roi7_con4(:,4);
              roi7_con4_betas = cell2mat(roi7_con4_beta);
        %from con5
           RPrecentralGyrus_BA6_con5.index = find(strcmp(grab_con5(:, strcmp(results_ref,'3.ROI')),roi_7));
            grab_roi7_con5= grab_con5((RPrecentralGyrus_BA6_con5.index),:);
                %grab betas 
              roi7_con5_beta = grab_roi7_con5(:,4);
              roi7_con5_betas = cell2mat(roi7_con5_beta);
        %from con6
           RPrecentralGyrus_BA6_con6.index = find(strcmp(grab_con6(:, strcmp(results_ref,'3.ROI')),roi_7));
            grab_roi7_con6 = grab_con6((RPrecentralGyrus_BA6_con6.index),:);
                %grab betas 
              roi7_con6_beta = grab_roi7_con6(:,4);
              roi7_con6_betas = cell2mat(roi7_con6_beta);
              
              
     % 8. roi_8 = ' roi_8 = 'sphere_10-1_1_57_MidlinePreSMA(BA6)''
        
        %from con1
           MidlinePreSMA_BA6_con1.index = find(strcmp(grab_con1(:, strcmp(results_ref,'3.ROI')),roi_8));
            grab_roi8_con1 = grab_con1((MidlinePreSMA_BA6_con1.index),:);
                 %grab betas 
                   roi8_con1_beta = grab_roi8_con1(:,4);
                   roi8_con1_betas = cell2mat(roi8_con1_beta);
        % from con2
           MidlinePreSMA_BA6_con2.index = find(strcmp(grab_con2(:, strcmp(results_ref,'3.ROI')),roi_8));
            grab_roi8_con2 = grab_con2((MidlinePreSMA_BA6_con2.index),:);
              %grab betas 
                roi8_con2_beta = grab_roi8_con2(:,4);
                roi8_con2_betas = cell2mat(roi8_con2_beta);
        %from con3
           MidlinePreSMA_BA6_con3.index = find(strcmp(grab_con3(:, strcmp(results_ref,'3.ROI')),roi_8));
            grab_roi8_con3 = grab_con3((MidlinePreSMA_BA6_con3.index),:);
                %grab betas 
              roi8_con3_beta = grab_roi8_con3(:,4);
              roi8_con3_betas = cell2mat(roi8_con3_beta);
        %from con4
           MidlinePreSMA_BA6_con4.index = find(strcmp(grab_con4(:, strcmp(results_ref,'3.ROI')),roi_8));
            grab_roi8_con4= grab_con4((MidlinePreSMA_BA6_con4.index),:);
                %grab betas 
              roi8_con4_beta = grab_roi8_con4(:,4);
              roi8_con4_betas = cell2mat(roi8_con4_beta);
        %from con5
           MidlinePreSMA_BA6_con5.index = find(strcmp(grab_con5(:, strcmp(results_ref,'3.ROI')),roi_8));
            grab_roi8_con5= grab_con5((MidlinePreSMA_BA6_con5.index),:);
                %grab betas 
              roi8_con5_beta = grab_roi8_con5(:,4);
              roi8_con5_betas = cell2mat(roi8_con5_beta);
        %from con6
           MidlinePreSMA_BA6_con6.index = find(strcmp(grab_con6(:, strcmp(results_ref,'3.ROI')),roi_8));
            grab_roi8_con6 = grab_con6((MidlinePreSMA_BA6_con6.index),:);
                %grab betas 
              roi8_con6_beta = grab_roi8_con6(:,4);
              roi8_con6_betas = cell2mat(roi8_con6_beta);

              
              
               % 9. roi_9 = 'sphere_6--14_5_16_LCaudate'
        
        %from con1
          LCaudate_con1.index = find(strcmp(grab_con1(:, strcmp(results_ref,'3.ROI')),roi_9));
            grab_roi9_con1 = grab_con1((LCaudate_con1.index),:);
                 %grab betas 
                   roi9_con1_beta = grab_roi9_con1(:,4);
                   roi9_con1_betas = cell2mat(roi9_con1_beta);
        % from con2
          LCaudate_con2.index = find(strcmp(grab_con2(:, strcmp(results_ref,'3.ROI')),roi_9));
            grab_roi9_con2 = grab_con2((LCaudate_con2.index),:);
              %grab betas 
                roi9_con2_beta = grab_roi9_con2(:,4);
                roi9_con2_betas = cell2mat(roi9_con2_beta);
        %from con3
          LCaudate_con3.index = find(strcmp(grab_con3(:, strcmp(results_ref,'3.ROI')),roi_9));
            grab_roi9_con3 = grab_con3((LCaudate_con3.index),:);
                %grab betas 
              roi9_con3_beta = grab_roi9_con3(:,4);
              roi9_con3_betas = cell2mat(roi9_con3_beta);
        %from con4
          LCaudate_con4.index = find(strcmp(grab_con4(:, strcmp(results_ref,'3.ROI')),roi_9));
            grab_roi9_con4= grab_con4((LCaudate_con4.index),:);
                %grab betas 
              roi9_con4_beta = grab_roi9_con4(:,4);
              roi9_con4_betas = cell2mat(roi9_con4_beta);
        %from con5
          LCaudate_con5.index = find(strcmp(grab_con5(:, strcmp(results_ref,'3.ROI')),roi_9));
            grab_roi9_con5= grab_con5((LCaudate_con5.index),:);
                %grab betas 
              roi9_con5_beta = grab_roi9_con5(:,4);
              roi9_con5_betas = cell2mat(roi9_con5_beta);
        %from con6
          LCaudate_con6.index = find(strcmp(grab_con6(:, strcmp(results_ref,'3.ROI')),roi_9));
            grab_roi9_con6 = grab_con6((LCaudate_con6.index),:);
                %grab betas 
              roi9_con6_beta = grab_roi9_con6(:,4);
              roi9_con6_betas = cell2mat(roi9_con6_beta);

       
              
     
              
              
              
              %%%%% means and std of betas
              
              %now: r1, r2 , r3
              %easier: r(1,:), r(2,:), r(3,:)
              
              %mean
              %now: mean(r1), mean(r2)...
              %easier mean(r)
              
              mean_roi1_con1 = mean (roi1_con1_betas);
              mean_roi1_con2 = mean (roi1_con2_betas);
              mean_roi1_con3 = mean (roi1_con3_betas);
              mean_roi1_con4 = mean (roi1_con4_betas);
              mean_roi1_con5 = mean (roi1_con5_betas);
              mean_roi1_con6 = mean (roi1_con6_betas);
              std_roi1_con1 = std (roi1_con1_betas);
              std_roi1_con2 = std (roi1_con2_betas);
              std_roi1_con3 = std (roi1_con3_betas);
              std_roi1_con4 = std (roi1_con4_betas);
              std_roi1_con5 = std (roi1_con5_betas);
              std_roi1_con6 = std (roi1_con6_betas);
              
            
                 
              mean_roi1 = [mean_roi1_con1 mean_roi1_con2; 
                           mean_roi1_con3 mean_roi1_con4;
                           mean_roi1_con5 mean_roi1_con6];
              std_roi1 = [std_roi1_con1,std_roi1_con2,std_roi1_con3,std_roi1_con4,std_roi1_con5,std_roi1_con6];
              se_roi1 = [std_roi1_con1/sqrt(22) std_roi1_con2/sqrt(22);
                         std_roi1_con3/sqrt(22) std_roi1_con4/sqrt(22);
                         std_roi1_con5/sqrt(22) std_roi1_con6/sqrt(22)];
                     
    

             
              mean_roi2_con1 = mean (roi2_con1_betas);
              mean_roi2_con2 = mean (roi2_con2_betas);
              mean_roi2_con3 = mean (roi2_con3_betas);
              mean_roi2_con4 = mean (roi2_con4_betas);
              mean_roi2_con5 = mean (roi2_con5_betas);
              mean_roi2_con6 = mean (roi2_con6_betas);
              std_roi2_con1 = std (roi2_con1_betas);
              std_roi2_con2 = std (roi2_con2_betas);
              std_roi2_con3 = std (roi2_con3_betas);
              std_roi2_con4 = std (roi2_con4_betas);
              std_roi2_con5 = std (roi2_con5_betas);
              std_roi2_con6 = std (roi2_con6_betas);
              
              
              mean_roi2 = [mean_roi2_con1,mean_roi2_con2;
                           mean_roi2_con3,mean_roi2_con4;
                           mean_roi2_con5,mean_roi2_con6];
              std_roi2 = [std_roi2_con1,std_roi2_con2,std_roi2_con3,std_roi2_con4,std_roi2_con5,std_roi2_con6];
              se_roi2 = [std_roi2_con1/sqrt(22) std_roi2_con2/sqrt(22);
                         std_roi2_con3/sqrt(22) std_roi2_con4/sqrt(22);
                         std_roi2_con5/sqrt(22),std_roi2_con6/sqrt(22)];
              
              
              mean_roi3_con1 = mean (roi3_con1_betas);
              mean_roi3_con2 = mean (roi3_con2_betas);
              mean_roi3_con3 = mean (roi3_con3_betas);
              mean_roi3_con4 = mean (roi3_con4_betas);
              mean_roi3_con5 = mean (roi3_con5_betas);
              mean_roi3_con6 = mean (roi3_con6_betas);
              std_roi3_con1 = std (roi3_con1_betas);
              std_roi3_con2 = std (roi3_con2_betas);
              std_roi3_con3 = std (roi3_con3_betas);
              std_roi3_con4 = std (roi3_con4_betas);
              std_roi3_con5 = std (roi3_con5_betas);
              std_roi3_con6 = std (roi3_con6_betas);
              
              mean_roi3 = [mean_roi3_con1,mean_roi3_con2;
                           mean_roi3_con3,mean_roi3_con4;
                           mean_roi3_con5,mean_roi3_con6];
              std_roi3 = [std_roi3_con1,std_roi3_con2,std_roi3_con3,std_roi3_con4,std_roi3_con5,std_roi3_con6];
              se_roi3 = [std_roi3_con1/sqrt(22) std_roi3_con2/sqrt(22);
                        std_roi3_con3/sqrt(22) std_roi3_con4/sqrt(22);
                        std_roi3_con5/sqrt(22) std_roi3_con6/sqrt(22)];
              
              
              mean_roi4_con1 = mean (roi4_con1_betas);
              mean_roi4_con2 = mean (roi4_con2_betas);
              mean_roi4_con3 = mean (roi4_con3_betas);
              mean_roi4_con4 = mean (roi4_con4_betas);
              mean_roi4_con5 = mean (roi4_con5_betas);
              mean_roi4_con6 = mean (roi4_con6_betas);
              std_roi4_con1 = std (roi4_con1_betas);
              std_roi4_con2 = std (roi4_con2_betas);
              std_roi4_con3 = std (roi4_con3_betas);
              std_roi4_con4 = std (roi4_con4_betas);
              std_roi4_con5 = std (roi4_con5_betas);
              std_roi4_con6 = std (roi4_con6_betas);
              
              
              mean_roi4 = [mean_roi4_con1,mean_roi4_con2;
                           mean_roi4_con3,mean_roi4_con4;
                           mean_roi4_con5,mean_roi4_con6];
              std_roi4 = [std_roi4_con1,std_roi4_con2,std_roi4_con3,std_roi4_con4,std_roi4_con5,std_roi4_con6];
              se_roi4 = [std_roi4_con1/sqrt(22) std_roi4_con2/sqrt(22);
                         std_roi4_con3/sqrt(22) std_roi4_con4/sqrt(22);
                         std_roi4_con5/sqrt(22) std_roi4_con6/sqrt(22)];
              
              mean_roi5_con1 = mean (roi5_con1_betas);
              mean_roi5_con2 = mean (roi5_con2_betas);
              mean_roi5_con3 = mean (roi5_con3_betas);
              mean_roi5_con4 = mean (roi5_con4_betas);
              mean_roi5_con5 = mean (roi5_con5_betas);
              mean_roi5_con6 = mean (roi5_con6_betas);
              std_roi5_con1 = std (roi5_con1_betas);
              std_roi5_con2 = std (roi5_con2_betas);
              std_roi5_con3 = std (roi5_con3_betas);
              std_roi5_con4 = std (roi5_con4_betas);
              std_roi5_con5 = std (roi5_con5_betas);
              std_roi5_con6 = std (roi5_con6_betas);
              
              mean_roi5 = [mean_roi5_con1,mean_roi5_con2;
                           mean_roi5_con3,mean_roi5_con4;
                           mean_roi5_con5,mean_roi5_con6];
              std_roi5 = [std_roi5_con1,std_roi5_con2,std_roi5_con3,std_roi5_con4,std_roi5_con5,std_roi5_con6];
              se_roi5 = [std_roi5_con1/sqrt(22) std_roi5_con2/sqrt(22);
                         std_roi5_con3/sqrt(22),std_roi5_con4/sqrt(22);
                         std_roi5_con5/sqrt(22),std_roi5_con6/sqrt(22)];
              
              
              mean_roi6_con1 = mean (roi6_con1_betas);
              mean_roi6_con2 = mean (roi6_con2_betas);
              mean_roi6_con3 = mean (roi6_con3_betas);
              mean_roi6_con4 = mean (roi6_con4_betas);
              mean_roi6_con5 = mean (roi6_con5_betas);
              mean_roi6_con6 = mean (roi6_con6_betas);
              std_roi6_con1 = std (roi6_con1_betas);
              std_roi6_con2 = std (roi6_con2_betas);
              std_roi6_con3 = std (roi6_con3_betas);
              std_roi6_con4 = std (roi6_con4_betas);
              std_roi6_con5 = std (roi6_con5_betas);
              std_roi6_con6 = std (roi6_con6_betas);
              
   
              mean_roi6 = [mean_roi6_con1,mean_roi6_con2;
                           mean_roi6_con3,mean_roi6_con4;
                           mean_roi6_con5,mean_roi6_con6];
              std_roi6 = [std_roi6_con1,std_roi6_con2,std_roi6_con3,std_roi6_con4,std_roi6_con5,std_roi6_con6];
              se_roi6 = [std_roi6_con1/sqrt(22) std_roi6_con2/sqrt(22);
                         std_roi6_con3/sqrt(22),std_roi6_con4/sqrt(22);
                         std_roi6_con5/sqrt(22),std_roi6_con6/sqrt(22)];
                     
                     
              mean_roi7_con1 = mean (roi7_con1_betas);
              mean_roi7_con2 = mean (roi7_con2_betas);
              mean_roi7_con3 = mean (roi7_con3_betas);
              mean_roi7_con4 = mean (roi7_con4_betas);
              mean_roi7_con5 = mean (roi7_con5_betas);
              mean_roi7_con6 = mean (roi7_con6_betas);
              std_roi7_con1 = std (roi7_con1_betas);
              std_roi7_con2 = std (roi7_con2_betas);
              std_roi7_con3 = std (roi7_con3_betas);
              std_roi7_con4 = std (roi7_con4_betas);
              std_roi7_con5 = std (roi7_con5_betas);
              std_roi7_con6 = std (roi7_con6_betas);
              
              mean_roi7 = [mean_roi7_con1,mean_roi7_con2;
                           mean_roi7_con3,mean_roi7_con4;
                           mean_roi7_con5,mean_roi7_con6];
              std_roi7 = [std_roi7_con1,std_roi7_con2,std_roi7_con3,std_roi7_con4,std_roi7_con5,std_roi7_con6];
              se_roi7 = [std_roi7_con1/sqrt(22) std_roi7_con2/sqrt(22);
                         std_roi7_con3/sqrt(22),std_roi7_con4/sqrt(22);
                         std_roi7_con5/sqrt(22),std_roi7_con6/sqrt(22)];

   

                     
              mean_roi8_con1 = mean (roi8_con1_betas);
              mean_roi8_con2 = mean (roi8_con2_betas);
              mean_roi8_con3 = mean (roi8_con3_betas);
              mean_roi8_con4 = mean (roi8_con4_betas);
              mean_roi8_con5 = mean (roi8_con5_betas);
              mean_roi8_con6 = mean (roi8_con6_betas);
              std_roi8_con1 = std (roi8_con1_betas);
              std_roi8_con2 = std (roi8_con2_betas);
              std_roi8_con3 = std (roi8_con3_betas);
              std_roi8_con4 = std (roi8_con4_betas);
              std_roi8_con5 = std (roi8_con5_betas);
              std_roi8_con6 = std (roi8_con6_betas);
              
                            mean_roi8 = [mean_roi8_con1,mean_roi8_con2;
                           mean_roi8_con3,mean_roi8_con4;
                           mean_roi8_con5,mean_roi8_con6];
              std_roi8 = [std_roi8_con1,std_roi8_con2,std_roi8_con3,std_roi8_con4,std_roi8_con5,std_roi8_con6];
              se_roi8 = [std_roi8_con1/sqrt(22) std_roi8_con2/sqrt(22);
                         std_roi8_con3/sqrt(22),std_roi8_con4/sqrt(22);
                         std_roi8_con5/sqrt(22),std_roi8_con6/sqrt(22)];
                     
                     
                     
                         mean_roi9_con1 = mean (roi9_con1_betas);
              mean_roi9_con2 = mean (roi9_con2_betas);
              mean_roi9_con3 = mean (roi9_con3_betas);
              mean_roi9_con4 = mean (roi9_con4_betas);
              mean_roi9_con5 = mean (roi9_con5_betas);
              mean_roi9_con6 = mean (roi9_con6_betas);
              std_roi9_con1 = std (roi9_con1_betas);
              std_roi9_con2 = std (roi9_con2_betas);
              std_roi9_con3 = std (roi9_con3_betas);
              std_roi9_con4 = std (roi9_con4_betas);
              std_roi9_con5 = std (roi9_con5_betas);
              std_roi9_con6 = std (roi9_con6_betas);
              
                            mean_roi9 = [mean_roi9_con1,mean_roi9_con2;
                           mean_roi9_con3,mean_roi9_con4;
                           mean_roi9_con5,mean_roi9_con6];
              std_roi9 = [std_roi9_con1,std_roi9_con2,std_roi9_con3,std_roi9_con4,std_roi9_con5,std_roi9_con6];
              se_roi9 = [std_roi9_con1/sqrt(22) std_roi9_con2/sqrt(22);
                         std_roi9_con3/sqrt(22),std_roi9_con4/sqrt(22);
                         std_roi9_con5/sqrt(22),std_roi9_con6/sqrt(22)];
   
   
          
   
              
              
%subject number = 22             
              
% Labeling: Encoding Target Language  as 1
    Encoding_TL = cell(22,1);
    Encoding_TL(:) = {'1'};
    TL = cell2mat(Encoding_TL);
% Labeling: Encoding Linguisituc Rule as 2
    Encoding_RL = cell(22,1); 
    Encoding_RL(:) = {'2'};
    RL = cell2mat(Encoding_RL);
% Labeling: Execution as 3 
    Execution = cell(22,1); 
    Execution(:) = {'3'};
    Exe = cell2mat(Execution);

% Labeling: English  as 0
    English = cell(22,1);
    English(:) = {'0'}; 
    Eng = cell2mat(English);
% Labeling: Spanish  as 1
    Spanish = cell(22,1);
    Spanish(:) = {'1'};
    Spa = cell2mat(Spanish);
    
TaskPhase = [Encoding_TL; Encoding_TL; Encoding_RL; Encoding_RL; Execution; Execution];
Lang = [English; Spanish; English; Spanish; English; Spanish];
   
    
    
% 1. roi_1 = 'sphere_10-0_32_24_AnteriorCingulate'
AnteriorCingulate_Data_Y = [roi1_con1_betas; roi1_con2_betas; roi1_con3_betas; roi1_con4_betas; roi1_con5_betas; roi1_con6_betas];
[p,table1,stats1,terms] = anovan(AnteriorCingulate_Data_Y,{TaskPhase,Lang},'model','interaction','display','on');
statdisptable(table1,'0_32_24_AnteriorCingulate',' ',' ',[-1 -1 -1 -1 -1 2 4])
a = cellfun(@isempty,table1);
table1(a) = {0};
b1_1 = table1(2:6,2:3);
b1_2 = table1(2:6,5:7);
c1_1 = cell2mat(b1_1);
c1_2 = cell2mat(b1_2);
AnteriorCingulate = horzcat(c1_1,c1_2)


% 2. roi_2 = 'sphere_8--31_18_-2_LInferiorFrontalGyrus_BA47'
LInferiorFrontalGyrus_BA47_Data_Y = [roi2_con1_betas; roi2_con2_betas; roi2_con3_betas; roi2_con4_betas; roi2_con5_betas; roi2_con6_betas];
[p,table2,stats2,terms] = anovan(LInferiorFrontalGyrus_BA47_Data_Y,{TaskPhase,Lang},'model','interaction','display','on');
statdisptable(table2,'-31_18_-2_LInferiorFrontalGyrus_BA47',' ',' ',[-1 -1 -1 -1 -1 2 4])
a2 = cellfun(@isempty,table2);
table2(a) = {0};
b2_1 = table2(2:6,2:3);
b2_2 = table2(2:6,5:7);
c2_1 = cell2mat(b2_1);
c2_2 = cell2mat(b2_2);
LInferiorFrontalGyrus_BA47 = horzcat(c2_1,c2_2)


% 3.roi_3 = 'sphere_8--44_13_29_LMiddleFrontalGyrus(BA46)'
LMiddleFrontalGyrus_Data_Y = [roi3_con1_betas; roi3_con2_betas; roi3_con3_betas; roi3_con4_betas; roi3_con5_betas; roi3_con6_betas];
[p,table3,stats3,terms] = anovan(LMiddleFrontalGyrus_Data_Y,{TaskPhase,Lang},'model','interaction','display','on');
statdisptable(table3,'-44_13_29_LMiddleFrontalGyrus(BA46)',' ',' ',[-1 -1 -1 -1 -1 2 4])
a = cellfun(@isempty,table3);
table3(a) = {0};
b3_1 = table3(2:6,2:3);
b3_2 = table3(2:6,5:7);
c3_1 = cell2mat(b3_1);
c3_2 = cell2mat(b3_2);
LMiddleFrontalGyrus = horzcat(c3_1,c3_2)


% 4. roi_4 = 'sphere_8--48_-42_-6_LMiddleTemporalGyrus(BA37)'
LMiddleTemporalGyrus_Data_Y = [roi4_con1_betas; roi4_con2_betas; roi4_con3_betas; roi4_con4_betas; roi4_con5_betas; roi4_con6_betas];
[p,table4,stats4,terms] = anovan(LMiddleTemporalGyrus_Data_Y,{TaskPhase,Lang},'model','interaction','display','on');
statdisptable(table4,'-48_-42_-6_LMiddleTemporalGyrus(BA37)',' ',' ',[-1 -1 -1 -1 -1 2 4])
a = cellfun(@isempty,table4);
table4(a) = {0};
b4_1 = table4(2:6,2:3);
b4_2 = table4(2:6,5:7);
c4_1 = cell2mat(b4_1);
c4_2 = cell2mat(b4_2);
LMiddleTemporalGyrus = horzcat(c4_1,c4_2)


% 5. roi_5 = 'sphere_8--48_15_11_LInferiorFrontalGyrus(BA44)'
LInferiorFrontalGyrus_BA44_Data_Y = [roi5_con1_betas; roi5_con2_betas; roi5_con3_betas; roi5_con4_betas; roi5_con5_betas; roi5_con6_betas];
[p,table5,stats5,terms] = anovan(LInferiorFrontalGyrus_BA44_Data_Y,{TaskPhase,Lang},'model','interaction','display','on');
statdisptable(table5,'-48_15_11_LInferiorFrontalGyrus(BA44)',' ',' ',[-1 -1 -1 -1 -1 2 4])
a = cellfun(@isempty,table5);
table5(a) = {0};
b5_1 = table5(2:6,2:3);
b5_2 = table5(2:6,5:7);
c5_1 = cell2mat(b5_1);
c5_2 = cell2mat(b5_2);
LInferiorFrontalGyrus_BA44 = horzcat(c5_1,c5_2)


% 6.roi_6 = 'sphere_6-14_5_16_RCaudate' 
RCaudate_Data_Y = [roi6_con1_betas; roi6_con2_betas; roi6_con3_betas; roi6_con4_betas; roi6_con5_betas; roi6_con6_betas];
[p,table6,stats6,terms] = anovan(RCaudate_Data_Y,{TaskPhase,Lang},'model','interaction','display','on');
statdisptable(table6,'14_5_16_RCaudate',' ',' ',[-1 -1 -1 -1 -1 2 4])
a = cellfun(@isempty,table6);
table6(a) = {0};
b6_1 = table6(2:6,2:3);
b6_2 = table6(2:6,5:7);
c6_1 = cell2mat(b6_1);
c6_2 = cell2mat(b6_2);
RCaudate= horzcat(c6_1,c6_2)

% 7. roi_7 = 'sphere_8-40_-9_32_RPrecentralCyrus(BA6)'
RPrecentralGyrus_Data_Y = [roi7_con1_betas; roi7_con2_betas; roi7_con3_betas; roi7_con4_betas; roi7_con5_betas; roi7_con6_betas];
[p,table7,stats7,terms] = anovan(RPrecentralGyrus_Data_Y,{TaskPhase,Lang},'model','interaction','display','on');
statdisptable(table7,'40_-9_32_RPrecentralCyrus(BA6)',' ',' ',[-1 -1 -1 -1 -1 2 4])
a = cellfun(@isempty,table7);
table7(a) = {0};
b7_1 = table7(2:6,2:3);
b7_2 = table7(2:6,5:7);
c7_1 = cell2mat(b7_1);
c7_2 = cell2mat(b7_2);
RPrecentralGyrus = horzcat(c7_1,c7_2)


% 8. roi_8 = 'sphere_10-1_1_57_MidlinePreSMA(BA6)'
MidlinePreSMA_Data_Y = [roi8_con1_betas; roi8_con2_betas; roi8_con3_betas; roi8_con4_betas; roi8_con5_betas; roi8_con6_betas];
[p,table8,stats8,terms] = anovan(MidlinePreSMA_Data_Y,{TaskPhase,Lang},'model','interaction','display','on');
statdisptable(table8,'1_1_57_MidlinePreSMA(BA6)',' ',' ',[-1 -1 -1 -1 -1 2 4])
a = cellfun(@isempty,table8);
table8(a) = {0};
b8_1 = table8(2:6,2:3);
b8_2 = table8(2:6,5:7);
c8_1 = cell2mat(b8_1);
c8_2 = cell2mat(b8_2);
MidlinePreSMA = horzcat(c8_1,c8_2)


% 9. roi_9 = 'sphere_6--14_5_16_LCaudate'
LCaudate_Data_Y = [roi9_con1_betas; roi9_con2_betas; roi9_con3_betas; roi9_con4_betas; roi9_con5_betas; roi9_con6_betas];
[p,table9,stats9,terms] = anovan(LCaudate_Data_Y,{TaskPhase,Lang},'model','interaction','display','on');
statdisptable(table9,'-14_5_16_LCaudate',' ',' ',[-1 -1 -1 -1 -1 2 4])
a = cellfun(@isempty,table9);
table9(a) = {0};
b9_1 = table9(2:6,2:3);
b9_2 = table9(2:6,5:7);
c9_1 = cell2mat(b9_1);
c9_2 = cell2mat(b9_2);
LCaudate = horzcat(c9_1,c9_2)
 
 [c1,m1,h1,nms1]= multcompare(stats1)
 [c2,m2,h2,nms2]= multcompare(stats2)
 [c3,m3,h3,nms3]= multcompare(stats3)
 [c4,m4,h4,nms4]= multcompare(stats4)
 [c5,m5,h5,nms5]= multcompare(stats5)
 [c6,m6,h6,nms6]= multcompare(stats6)
 [c7,m7,h7,nms7]= multcompare(stats7)
 [c8,m8,h8,nms8]= multcompare(stats8)
 [c9,m9,h9,nms9]= multcompare(stats9)



 % roi1
figure(13)
clf

 h1 = bar(mean_roi1);
 hold on
  %set(h1,'Color','r')
  set(gca, 'XTickLabel', {'Encoding TL'; 'Encoding RL'; 'Executing'}) 
 legendLabel = ['English';'Spanish'];
 legend(h1,legendLabel);
 title('AnteriorCingulate')
 xlabel('Task Phase')
 ylabel('Mean ROI (beta weights)')

 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi1(:,1), se_roi1(:,1));
 e2 = errorbar(foo+.15,mean_roi1(:,2), se_roi1(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')

 ylim([-.5 2.5])
 
 
 
 
% roi2
figure(14)
clf
 
 h2 = bar(mean_roi2)
 hold on
 %set(h2,'Color','r')
 set(gca, 'XTickLabel', {'Encoding TL'; 'Encoding RL'; 'Executing'}) 
 legendLabel = ['English';'Spanish'];
 legend(h2,legendLabel);
 title('LinferiorFrontalGyrus BA47')
 xlabel('Task Phase')
 ylabel('Mean ROI (beta weights)')

 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi2(:,1), se_roi2(:,1));
 e2 = errorbar(foo+.15,mean_roi2(:,2), se_roi2(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])
 
 %roi3
figure(15)  
clf
 h3 = bar(mean_roi3);
 hold on
  %set(h3,'Color','r')
 set(gca, 'XTickLabel', {'Encoding TL'; 'Encoding RL'; 'Executing'}) 
 legendLabel = ['English';'Spanish'];
 legend(h3,legendLabel);
 title('LMiddleFrontalGyrus BA46')
 xlabel('Task Phase')
 ylabel('Mean ROI (beta weights)')
 

 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi3(:,1), se_roi3(:,1));
 e2 = errorbar(foo+.15,mean_roi3(:,2), se_roi3(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])
 
 %roi4
figure(16)  
  clf
  h4 = bar(mean_roi4);
 hold on
  %set(h4,'Color','r')
 set(gca, 'XTickLabel', {'Encoding TL'; 'Encoding RL'; 'Executing'}) 
 legendLabel = ['English';'Spanish'];
 legend(h4,legendLabel);
 title('LMiddleTemporalGyrus BA37')
 xlabel('Task Phase')
 ylabel('Mean ROI (beta weights)')

 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi4(:,1), se_roi4(:,1));
 e2 = errorbar(foo+.15,mean_roi4(:,2), se_roi4(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])

   
 % roi5
 figure(17)
 clf
 h5= bar(mean_roi5);
 hold on
  %set(h,'Color','r')
 set(gca, 'XTickLabel', {'Encoding TL'; 'Encoding RL'; 'Executing'}) 
 legendLabel = ['English';'Spanish'];
 legend(h5,legendLabel);
 title('LInferiorFrontalGyrus BA44)')
 xlabel('Task Phase')
 ylabel('Mean ROI (beta weights)')

 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi5(:,1), se_roi5(:,1));
 e2 = errorbar(foo+.15,mean_roi5(:,2), se_roi5(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])

% roi6
 figure(18)
clf
 h6 = bar(mean_roi6);
 hold on
  %set(h6,'Color','r')
 set(gca, 'XTickLabel', {'Encoding TL'; 'Encoding RL'; 'Executing'}) 
 legendLabel = ['English';'Spanish'];
 legend(h6,legendLabel);
 title('RCaudate')
 xlabel('Task Phase')
 ylabel('Mean ROI (beta weights)')

 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi6(:,1), se_roi6(:,1));
 e2 = errorbar(foo+.15,mean_roi6(:,2), se_roi6(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])
 
 % roi7  
 figure(19)
   clf
 h7 = bar(mean_roi7);
 hold on
  %set(h7,'Color','r')
 set(gca, 'XTickLabel', {'Encoding TL'; 'Encoding RL'; 'Executing'}) 
 legendLabel = ['English';'Spanish'];
 legend(h7,legendLabel);
 title('RPrecentralGyrus BA6)')
 xlabel('Task Phase')
 ylabel('Mean ROI (beta weights)')

 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi7(:,1), se_roi7(:,1));
 e2 = errorbar(foo+.15,mean_roi7(:,2), se_roi7(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])
 
  
 % roi8 
 figure(20)
   clf
 h8 = bar(mean_roi8);
 hold on
  %set(h8,'Color','r')
 set(gca, 'XTickLabel', {'Encoding TL'; 'Encoding RL'; 'Executing'}) 
 legendLabel = ['English';'Spanish'];
 legend(h8,legendLabel);
 title('MidlinePreSMA BA6)')
 xlabel('Task Phase')
 ylabel('Mean ROI (beta weights)')

 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi8(:,1), se_roi8(:,1));
 e2 = errorbar(foo+.15,mean_roi8(:,2), se_roi8(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])
 
 %roi9
  figure(21)
   clf
 h9 = bar(mean_roi9);
 hold on
  %set(h9,'Color','r')
 set(gca, 'XTickLabel', {'Encoding TL'; 'Encoding RL'; 'Executing'}) 
 legendLabel = ['English';'Spanish'];
 legend(h9,legendLabel);
 title('LCaudate)')
 xlabel('Task Phase')
 ylabel('Mean ROI (beta weights)')

 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi9(:,1), se_roi9(:,1));
 e2 = errorbar(foo+.15,mean_roi9(:,2), se_roi9(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])
 


figure (25)
 
 
clf
subplot(3,4,1)

 h1 = bar(mean_roi1);
 hold on
  %set(h1,'Color','r')
  
 set(gca, 'XTickLabel', {'Encoding TL'; 'Encoding RL'; 'Executing'}) 
 legendLabel = ['English';'Spanish'];
 legend(h1,legendLabel);
 title('AnteriorCingulate')
 xlabel('Task Phase')
 ylabel('Mean ROI (beta weights)')

 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi1(:,1), se_roi1(:,1));
 e2 = errorbar(foo+.15,mean_roi1(:,2), se_roi1(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')

 ylim([-.5 2.5])
 
 
 %14
 subplot(3,4,2)
 h2 = bar(mean_roi2);
 hold on
 title('LInferiorFrontalGyrus BA47')
 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi2(:,1), se_roi2(:,1));
 e2 = errorbar(foo+.15,mean_roi2(:,2), se_roi2(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])

 % 15 
 subplot(3,4,3)
 h3 = bar(mean_roi3);
 hold on
 title('LMiddleFrontalGyrus BA46')
 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi3(:,1), se_roi3(:,1));
 e2 = errorbar(foo+.15,mean_roi3(:,2), se_roi3(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])
 
 
 %16
 subplot(3,4,4)
 h4 = bar(mean_roi4);
 hold on
 title('LMiddleTemporalGyrus BA37')
foo = [1 2 3];
e1 = errorbar(foo-.15,mean_roi4(:,1), se_roi4(:,1));
e2 = errorbar(foo+.15,mean_roi4(:,2), se_roi4(:,2));
set(e1,'LineStyle','none','Color','R')
set(e2,'LineStyle','none','Color','R')
ylim([-.5 2.5])

%17
 subplot(3,4,5)
 h5= bar(mean_roi5);
 hold on
 title('LInferiorFrontalGyrus BA44')
 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi5(:,1), se_roi5(:,1));
 e2 = errorbar(foo+.15,mean_roi5(:,2), se_roi5(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])

% 18
subplot(3,4,6)
 h6 = bar(mean_roi6);
 hold on
 title('RCaudate')
 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi6(:,1), se_roi6(:,1));
 e2 = errorbar(foo+.15,mean_roi6(:,2), se_roi6(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])
 
  
%19
subplot(3,4,7)
 h7 = bar(mean_roi7);
 hold on
  title('RPrecentralGyrus BA6')
 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi7(:,1), se_roi7(:,1));
 e2 = errorbar(foo+.15,mean_roi7(:,2), se_roi7(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])
 
 %20
subplot(3,4,8)
 h8 = bar(mean_roi8);
 hold on
  title('MidlinePreSMA BA6')
 foo = [1 2 3];
 e1 = errorbar(foo-.15,mean_roi8(:,1), se_roi8(:,1));
 e2 = errorbar(foo+.15,mean_roi8(:,2), se_roi8(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])
 
 %21
subplot(3,4,9)
 h9 = bar(mean_roi9);
 hold on
  title('L Caudate')
 foo = [1 2 3]
 e1 = errorbar(foo-.15,mean_roi9(:,1), se_roi9(:,1));
 e2 = errorbar(foo+.15,mean_roi9(:,2), se_roi9(:,2));
 set(e1,'LineStyle','none','Color','R')
 set(e2,'LineStyle','none','Color','R')
 ylim([-.5 2.5])

%Individual Plot
% roi1

a_multi1_12 = (roi1_con1_betas + roi1_con2_betas)/2;
b_multi1_12 = mean(a_multi1_12);
c_multi1_12 = std(a_multi1_12);
d_multi1_12 = c_multi1_12/sqrt(22);

a_multi1_34 = (roi1_con3_betas + roi1_con4_betas)/2;
b_multi1_34 = mean(a_multi1_34);
c_multi1_34 = std(a_multi1_34);
d_multi1_34 = c_multi1_34/sqrt(22);

a_multi1_56 = (roi1_con5_betas + roi1_con6_betas)/2;
b_multi1_56 = mean(a_multi1_56);
c_multi1_56 = std(a_multi1_56);
d_multi1_56 = c_multi1_56/sqrt(22);

ste_multi1_12 = [d_multi1_12 d_multi1_34 d_multi1_56]



f41 = figure(41)
clf



a = [1 2 3]
multi_b1 = (m1(:,1))
multi_h1 = bar(a, diag(multi_b1),'stacked')
set(multi_h1(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h1(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h1(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('AnteriorCingulate')
ylabel('Mean ROI (beta weights)')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m1(:,1),ste_multi1_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')




%roi2
a_multi2_12 = (roi2_con1_betas + roi2_con2_betas)/2;
b_multi2_12 = mean(a_multi2_12);
c_multi2_12 = std(a_multi2_12);
d_multi2_12 = c_multi2_12/sqrt(22);

a_multi2_34 = (roi2_con3_betas + roi2_con4_betas)/2;
b_multi2_34 = mean(a_multi2_34);
c_multi2_34 = std(a_multi2_34);
d_multi2_34 = c_multi2_34/sqrt(22);

a_multi2_56 = (roi2_con5_betas + roi2_con6_betas)/2;
b_multi2_56 = mean(a_multi2_56);
c_multi2_56 = std(a_multi2_56);
d_multi2_56 = c_multi2_56/sqrt(22);

ste_multi2_12 = [d_multi2_12 d_multi2_34 d_multi2_56]

f42 = figure(42)
clf


a = [1 2 3]
multi_b2 = (m2(:,1));
multi_h2 = bar(a, diag(multi_b2),'stacked')
set(multi_h2(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h2(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h2(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('LInferiorFrontalGyrus BA47')
ylabel('Mean ROI (beta weights)')
hold on

%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m2(:,1),ste_multi2_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')
%sigstar({[1,2],[2,3]},[0.05,0.05])

%roi3

a_multi3_12 = (roi3_con1_betas + roi3_con2_betas)/2;
b_multi3_12 = mean(a_multi3_12);
c_multi3_12 = std(a_multi3_12);
d_multi3_12 = c_multi3_12/sqrt(22);

a_multi3_34 = (roi3_con3_betas + roi3_con4_betas)/2;
b_multi3_34 = mean(a_multi3_34);
c_multi3_34 = std(a_multi3_34);
d_multi3_34 = c_multi3_34/sqrt(22);

a_multi3_56 = (roi3_con5_betas + roi3_con6_betas)/2;
b_multi3_56 = mean(a_multi3_56);
c_multi3_56 = std(a_multi3_56);
d_multi3_56 = c_multi3_56/sqrt(22);

ste_multi3_12 = [d_multi3_12 d_multi3_34 d_multi3_56]


f43 = figure(43)
clf


a = [1 2 3]
multi_b3 = (m3(:,1))
multi_h3 = bar(a, diag(multi_b3),'stacked')
set(multi_h3(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h3(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h3(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('LMiddleFrontalGyrus BA46')
ylabel('Mean ROI (beta weights)')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m3(:,1),ste_multi3_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')
%sigstar({[1,2], [1,3]},[0.001,0.001])

% roi4

a_multi4_12 = (roi4_con1_betas + roi4_con2_betas)/2;
b_multi4_12 = mean(a_multi4_12);
c_multi4_12 = std(a_multi4_12);
d_multi4_12 = c_multi4_12/sqrt(22);

a_multi4_34 = (roi4_con3_betas + roi4_con4_betas)/2;
b_multi4_34 = mean(a_multi4_34);
c_multi4_34 = std(a_multi4_34);
d_multi4_34 = c_multi4_34/sqrt(22);

a_multi4_56 = (roi4_con5_betas + roi4_con6_betas)/2;
b_multi4_56 = mean(a_multi4_56);
c_multi4_56 = std(a_multi4_56);
d_multi4_56 = c_multi4_56/sqrt(22);

ste_multi4_12 = [d_multi4_12 d_multi4_34 d_multi4_56]

f44 = figure(44)
clf



a = [1 2 3]
multi_b4 = (m4(:,1))
multi_h4 = bar(a, diag(multi_b4),'stacked')
set(multi_h4(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h4(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h4(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('LMiddleTemporalGyrus BA37')
ylabel('Mean ROI (beta weights)')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m4(:,1),ste_multi4_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')
%sigstar({[1,2], [1,3]},[0.001,0.001])


%roi5

a_multi5_12 = (roi5_con1_betas + roi5_con2_betas)/2;
b_multi5_12 = mean(a_multi5_12);
c_multi5_12 = std(a_multi5_12);
d_multi5_12 = c_multi5_12/sqrt(22);

a_multi5_34 = (roi5_con3_betas + roi5_con4_betas)/2;
b_multi5_34 = mean(a_multi5_34);
c_multi5_34 = std(a_multi5_34);
d_multi5_34 = c_multi5_34/sqrt(22);

a_multi5_56 = (roi5_con5_betas + roi5_con6_betas)/2;
b_multi5_56 = mean(a_multi5_56);
c_multi5_56 = std(a_multi5_56);
d_multi5_56 = c_multi5_56/sqrt(22);

ste_multi5_12 = [d_multi5_12 d_multi5_34 d_multi5_56]


f45 = figure(45)
clf

a = [1 2 3]
multi_b5 = (m5(:,1))
multi_h5 = bar(a, diag(multi_b5),'stacked')
set(multi_h5(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h5(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h5(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('LInferiorFrontalGyrus BA44')
ylabel('Mean ROI (beta weights)')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m5(:,1),ste_multi5_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')

%roi6


a_multi6_12 = (roi6_con1_betas + roi6_con2_betas)/2;
b_multi6_12 = mean(a_multi6_12);
c_multi6_12 = std(a_multi6_12);
d_multi6_12 = c_multi6_12/sqrt(22);

a_multi6_34 = (roi6_con3_betas + roi6_con4_betas)/2;
b_multi6_34 = mean(a_multi6_34);
c_multi6_34 = std(a_multi6_34);
d_multi6_34 = c_multi6_34/sqrt(22);

a_multi6_56 = (roi6_con5_betas + roi6_con6_betas)/2;
b_multi6_56 = mean(a_multi6_56);
c_multi6_56 = std(a_multi6_56);
d_multi6_56 = c_multi6_56/sqrt(22);

ste_multi6_12 = [d_multi6_12 d_multi6_34 d_multi6_56]


f46 = figure(46)
clf

a = [1 2 3]
multi_b6 = (m6(:,1))
multi_h6 = bar(a, diag(multi_b6),'stacked')
set(multi_h6(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h6(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h6(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('RCaudate')
ylabel('Mean ROI (beta weights)')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m6(:,1),ste_multi6_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')


 % roi7


a_multi7_12 = (roi7_con1_betas + roi7_con2_betas)/2;
b_multi7_12 = mean(a_multi7_12);
c_multi7_12 = std(a_multi7_12);
d_multi7_12 = c_multi7_12/sqrt(22);

a_multi7_34 = (roi7_con3_betas + roi7_con4_betas)/2;
b_multi7_34 = mean(a_multi7_34);
c_multi7_34 = std(a_multi7_34);
d_multi7_34 = c_multi7_34/sqrt(22);

a_multi7_56 = (roi7_con5_betas + roi7_con6_betas)/2;
b_multi7_56 = mean(a_multi7_56);
c_multi7_56 = std(a_multi7_56);
d_multi7_56 = c_multi7_56/sqrt(22);

ste_multi7_12 = [d_multi7_12 d_multi7_34 d_multi7_56]


f47 = figure(47)
clf

a = [1 2 3]
multi_b7 = (m7(:,1))
multi_h7 = bar(a, diag(multi_b7),'stacked')
set(multi_h7(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h7(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h7(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('RPrecentralGyrus BA6')
ylabel('Mean ROI (beta weights)')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m7(:,1),ste_multi7_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')
 


% roi8

a_multi8_12 = (roi8_con1_betas + roi8_con2_betas)/2;
b_multi8_12 = mean(a_multi8_12);
c_multi8_12 = std(a_multi8_12);
d_multi8_12 = c_multi8_12/sqrt(22);

a_multi8_34 = (roi8_con3_betas + roi8_con4_betas)/2;
b_multi8_34 = mean(a_multi8_34);
c_multi8_34 = std(a_multi8_34);
d_multi8_34 = c_multi8_34/sqrt(22);

a_multi8_56 = (roi8_con5_betas + roi8_con6_betas)/2;
b_multi8_56 = mean(a_multi8_56);
c_multi8_56 = std(a_multi8_56);
d_multi8_56 = c_multi8_56/sqrt(22);

ste_multi8_12 = [d_multi8_12 d_multi8_34 d_multi8_56]



f48 = figure(48)
clf



a = [1 2 3]
multi_b8 = (m8(:,1))
multi_h8 = bar(a, diag(multi_b8),'stacked')
set(multi_h8(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h8(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h8(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('MidlinePreSMA BA6')
ylabel('Mean ROI (beta weights)')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m8(:,1),ste_multi8_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')




%roi9
a_multi9_12 = (roi9_con1_betas + roi9_con2_betas)/2;
b_multi9_12 = mean(a_multi9_12);
c_multi9_12 = std(a_multi9_12);
d_multi9_12 = c_multi9_12/sqrt(22);

a_multi9_34 = (roi9_con3_betas + roi9_con4_betas)/2;
b_multi9_34 = mean(a_multi9_34);
c_multi9_34 = std(a_multi9_34);
d_multi9_34 = c_multi9_34/sqrt(22);

a_multi9_56 = (roi9_con5_betas + roi9_con6_betas)/2;
b_multi9_56 = mean(a_multi9_56);
c_multi9_56 = std(a_multi9_56);
d_multi9_56 = c_multi9_56/sqrt(22);

ste_multi9_12 = [d_multi9_12 d_multi9_34 d_multi9_56]

f49 = figure(49)
clf


a = [1 2 3]
multi_b9 = (m9(:,1));
multi_h9 = bar(a, diag(multi_b9),'stacked')
set(multi_h9(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h9(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h9(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('L Caudate')
ylabel('Mean ROI (beta weights)')
hold on

%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m9(:,1),ste_multi9_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')
%sigstar({[1,2],[2,3]},[0.05,0.05])
 
 
 
 
 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subplot
% roi1


a_multi1_12 = (roi1_con1_betas + roi1_con2_betas)/2;
b_multi1_12 = mean(a_multi1_12);
c_multi1_12 = std(a_multi1_12);
d_multi1_12 = c_multi1_12/sqrt(22);

a_multi1_34 = (roi1_con3_betas + roi1_con4_betas)/2;
b_multi1_34 = mean(a_multi1_34);
c_multi1_34 = std(a_multi1_34);
d_multi1_34 = c_multi1_34/sqrt(22);

a_multi1_56 = (roi1_con5_betas + roi1_con6_betas)/2;
b_multi1_56 = mean(a_multi1_56);
c_multi1_56 = std(a_multi1_56);
d_multi1_56 = c_multi1_56/sqrt(22);

ste_multi1_12 = [d_multi1_12 d_multi1_34 d_multi1_56]


clf
f31 = figure(31)
subplot(3,4,1)



a = [1 2 3]
multi_b1 = (m1(:,1))
multi_h1 = bar(a, diag(multi_b1),'stacked')
set(multi_h1(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h1(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h1(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('AnteriorCingulate')
ylabel('Mean ROI (beta weights)')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m1(:,1),ste_multi1_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')




%roi2
a_multi2_12 = (roi2_con1_betas + roi2_con2_betas)/2;
b_multi2_12 = mean(a_multi2_12);
c_multi2_12 = std(a_multi2_12);
d_multi2_12 = c_multi2_12/sqrt(22);

a_multi2_34 = (roi2_con3_betas + roi2_con4_betas)/2;
b_multi2_34 = mean(a_multi2_34);
c_multi2_34 = std(a_multi2_34);
d_multi2_34 = c_multi2_34/sqrt(22);

a_multi2_56 = (roi2_con5_betas + roi2_con6_betas)/2;
b_multi2_56 = mean(a_multi2_56);
c_multi2_56 = std(a_multi2_56);
d_multi2_56 = c_multi2_56/sqrt(22);

ste_multi2_12 = [d_multi2_12 d_multi2_34 d_multi2_56]




subplot(3,4,2)


a = [1 2 3]
multi_b2 = (m2(:,1));
multi_h2 = bar(a, diag(multi_b2),'stacked')
set(multi_h2(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h2(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h2(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('LInferiorFrontalGyrus BA47')
hold on

%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m2(:,1),ste_multi2_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')
%sigstar({[1,2],[2,3]},[0.05,0.05])

%roi3

a_multi3_12 = (roi3_con1_betas + roi3_con2_betas)/2;
b_multi3_12 = mean(a_multi3_12);
c_multi3_12 = std(a_multi3_12);
d_multi3_12 = c_multi3_12/sqrt(22);

a_multi3_34 = (roi3_con3_betas + roi3_con4_betas)/2;
b_multi3_34 = mean(a_multi3_34);
c_multi3_34 = std(a_multi3_34);
d_multi3_34 = c_multi3_34/sqrt(22);

a_multi3_56 = (roi3_con5_betas + roi3_con6_betas)/2;
b_multi3_56 = mean(a_multi3_56);
c_multi3_56 = std(a_multi3_56);
d_multi3_56 = c_multi3_56/sqrt(22);

ste_multi3_12 = [d_multi3_12 d_multi3_34 d_multi3_56]


subplot(3,4,3)


a = [1 2 3]
multi_b3 = (m3(:,1))
multi_h3 = bar(a, diag(multi_b3),'stacked')
set(multi_h3(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h3(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h3(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('LMiddleFrontalGyrus BA46')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m3(:,1),ste_multi3_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')
%sigstar({[1,2], [1,3]},[0.001,0.001])

% roi4

a_multi4_12 = (roi4_con1_betas + roi4_con2_betas)/2;
b_multi4_12 = mean(a_multi4_12);
c_multi4_12 = std(a_multi4_12);
d_multi4_12 = c_multi4_12/sqrt(22);

a_multi4_34 = (roi4_con3_betas + roi4_con4_betas)/2;
b_multi4_34 = mean(a_multi4_34);
c_multi4_34 = std(a_multi4_34);
d_multi4_34 = c_multi4_34/sqrt(22);

a_multi4_56 = (roi4_con5_betas + roi4_con6_betas)/2;
b_multi4_56 = mean(a_multi4_56);
c_multi4_56 = std(a_multi4_56);
d_multi4_56 = c_multi4_56/sqrt(22);

ste_multi4_12 = [d_multi4_12 d_multi4_34 d_multi4_56]


subplot(3,4,4)



a = [1 2 3]
multi_b4 = (m4(:,1))
multi_h4 = bar(a, diag(multi_b4),'stacked')
set(multi_h4(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h4(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h4(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('LMiddleTemporalGyrus BA37')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m4(:,1),ste_multi4_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')
%sigstar({[1,2], [1,3]},[0.001,0.001])
%roi5

a_multi5_12 = (roi5_con1_betas + roi5_con2_betas)/2;
b_multi5_12 = mean(a_multi5_12);
c_multi5_12 = std(a_multi5_12);
d_multi5_12 = c_multi5_12/sqrt(22);

a_multi5_34 = (roi5_con3_betas + roi5_con4_betas)/2;
b_multi5_34 = mean(a_multi5_34);
c_multi5_34 = std(a_multi5_34);
d_multi5_34 = c_multi5_34/sqrt(22);

a_multi5_56 = (roi5_con5_betas + roi5_con6_betas)/2;
b_multi5_56 = mean(a_multi5_56);
c_multi5_56 = std(a_multi5_56);
d_multi5_56 = c_multi5_56/sqrt(22);

ste_multi5_12 = [d_multi5_12 d_multi5_34 d_multi5_56]


subplot(3,4,5)

a = [1 2 3]
multi_b5 = (m5(:,1))
multi_h5 = bar(a, diag(multi_b5),'stacked')
set(multi_h5(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h5(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h5(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('LInferiorFrontalGyrus BA44')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m5(:,1),ste_multi5_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')




%roi6


a_multi6_12 = (roi6_con1_betas + roi6_con2_betas)/2;
b_multi6_12 = mean(a_multi6_12);
c_multi6_12 = std(a_multi6_12);
d_multi6_12 = c_multi6_12/sqrt(22);

a_multi6_34 = (roi6_con3_betas + roi6_con4_betas)/2;
b_multi6_34 = mean(a_multi6_34);
c_multi6_34 = std(a_multi6_34);
d_multi6_34 = c_multi6_34/sqrt(22);

a_multi6_56 = (roi6_con5_betas + roi6_con6_betas)/2;
b_multi6_56 = mean(a_multi6_56);
c_multi6_56 = std(a_multi6_56);
d_multi6_56 = c_multi6_56/sqrt(22);

ste_multi6_12 = [d_multi6_12 d_multi6_34 d_multi6_56]


subplot(3,4,6)

a = [1 2 3]
multi_b6 = (m6(:,1))
multi_h6 = bar(a, diag(multi_b6),'stacked')
set(multi_h6(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h6(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h6(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('RCaudate')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m6(:,1),ste_multi6_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')


 % roi7


a_multi7_12 = (roi7_con1_betas + roi7_con2_betas)/2;
b_multi7_12 = mean(a_multi7_12);
c_multi7_12 = std(a_multi7_12);
d_multi7_12 = c_multi7_12/sqrt(22);

a_multi7_34 = (roi7_con3_betas + roi7_con4_betas)/2;
b_multi7_34 = mean(a_multi7_34);
c_multi7_34 = std(a_multi7_34);
d_multi7_34 = c_multi7_34/sqrt(22);

a_multi7_56 = (roi7_con5_betas + roi7_con6_betas)/2;
b_multi7_56 = mean(a_multi7_56);
c_multi7_56 = std(a_multi7_56);
d_multi7_56 = c_multi7_56/sqrt(22);

ste_multi7_12 = [d_multi7_12 d_multi7_34 d_multi7_56]


subplot(3,4,7)

a = [1 2 3]
multi_b7 = (m7(:,1))
multi_h7 = bar(a, diag(multi_b7),'stacked')
set(multi_h7(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h7(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h7(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('RPrecentralGyrus BA6')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m7(:,1),ste_multi7_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')



%roi8

a_multi8_12 = (roi8_con1_betas + roi8_con2_betas)/2;
b_multi8_12 = mean(a_multi8_12);
c_multi8_12 = std(a_multi8_12);
d_multi8_12 = c_multi8_12/sqrt(22);

a_multi8_34 = (roi8_con3_betas + roi8_con4_betas)/2;
b_multi8_34 = mean(a_multi8_34);
c_multi8_34 = std(a_multi8_34);
d_multi8_34 = c_multi8_34/sqrt(22);

a_multi8_56 = (roi8_con5_betas + roi8_con6_betas)/2;
b_multi8_56 = mean(a_multi8_56);
c_multi8_56 = std(a_multi8_56);
d_multi8_56 = c_multi8_56/sqrt(22);

ste_multi8_12 = [d_multi8_12 d_multi8_34 d_multi8_56]


subplot(3,4,8)


a = [1 2 3]
multi_b8 = (m8(:,1))
multi_h8 = bar(a, diag(multi_b8),'stacked')
set(multi_h8(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h8(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h8(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('MidlinePreSMA BA6')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m8(:,1),ste_multi8_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')
%sigstar({[1,2], [1,3]},[0.001,0.001])






%roi9

a_multi9_12 = (roi9_con1_betas + roi9_con2_betas)/2;
b_multi9_12 = mean(a_multi9_12);
c_multi9_12 = std(a_multi9_12);
d_multi9_12 = c_multi9_12/sqrt(22);

a_multi9_34 = (roi9_con3_betas + roi9_con4_betas)/2;
b_multi9_34 = mean(a_multi9_34);
c_multi9_34 = std(a_multi9_34);
d_multi9_34 = c_multi9_34/sqrt(22);

a_multi9_56 = (roi9_con5_betas + roi9_con6_betas)/2;
b_multi9_56 = mean(a_multi9_56);
c_multi9_56 = std(a_multi9_56);
d_multi9_56 = c_multi9_56/sqrt(22);

ste_multi9_12 = [d_multi9_12 d_multi9_34 d_multi9_56]


subplot(3,4,9)


a = [1 2 3]
multi_b9 = (m9(:,1))
multi_h9 = bar(a, diag(multi_b9),'stacked')
set(multi_h9(1),'FaceColor',[0.635294139385223 0.0784313753247261 0.184313729405403],...
    'EdgeColor',[0.635294139385223 0.0784313753247261 0.184313729405403]);
set(multi_h9(2),'FaceColor',[1 0.843137264251709 0],...
    'EdgeColor',[1 0.843137264251709 0]);
set(multi_h9(3),'FaceColor',[0 0.498039215803146 0],...
    'EdgeColor',[0 0.498039215803146 0]);
xlim([0, 4])
ylim([-0.5, 2.5])
title('L Caudate')
hold on
%Create Error Bar
errorbarlocation = [1 2 3];
errorbar(errorbarlocation,m9(:,1),ste_multi9_12,'LineStyle','none','LineWidth',1.5,'Color',[0 0 0]);

set(gca,'XTickLabel',{'EncdTL','EncdRL','Execut'},...
    'TickLength',[0 0],...
    'FontName','Hiragino Kaku Gothic ProN')
%sigstar({[1,2], [1,3]},[0.001,0.001])

%%subplot title

p1 = mtit(FileName1,...
        'fontsize', 14,...
        'color', [0 0 0],...
         'xoff', 0,...
         'yoff',.035);

         
         





